home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume2 / libraris / gimme.2 < prev    next >
Internet Message Format  |  1988-12-02  |  61KB

  1. Path: xanth!ames!nrl-cmf!ukma!rutgers!mit-eddie!ll-xn!adelie!infinet!ulowell!page
  2. From: page@swan.ulowell.edu (Bob Page)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v02i075:  gimme.lib - misc library routines, Part02/07
  5. Message-ID: <10413@swan.ulowell.edu>
  6. Date: 2 Dec 88 00:59:24 GMT
  7. Organization: University of Lowell, Computer Science Dept.
  8. Lines: 1670
  9. Approved: page@swan.ulowell.edu
  10.  
  11. Submitted-by: oscvax!jan@uunet.UU.NET (Jan Sven Trabandt)
  12. Posting-number: Volume 2, Issue 75
  13. Archive-name: libraries/gimme.2
  14.  
  15. #    This is a shell archive.
  16. #    Remove everything above and including the cut line.
  17. #    Then run the rest of the file through sh.
  18. #----cut here-----cut here-----cut here-----cut here----#
  19. #!/bin/sh
  20. # shar:    Shell Archiver
  21. #    Run the following text with /bin/sh to create:
  22. #    DOCS.part2
  23. # This archive created: Thu Dec  1 19:44:31 1988
  24. cat << \SHAR_EOF > DOCS.part2
  25.  *        short err;
  26.  *
  27.  * INPUTS:    struct IOStdReq *ioreq;     ioreq returned by addInputHandler
  28.  *
  29.  * DESCRIPTION: Remove an input handler to the system (previously added by
  30.  *        addInputHandler).
  31.  *
  32.  *        Note: the contents of the ioreq must be unchanged since the
  33.  *        preceding addInputHandler call.
  34.  *
  35.  * RESULTS:    Returns non-zero on error.
  36.  *
  37.  * SEE ALSO:    addInputHandler
  38.  */
  39.  
  40. /*
  41.  * NAME:    gimmeBorder
  42.  *
  43.  * SYNOPSIS:    border = gimmeBorder( memheadptr, xsize, ysize );
  44.  *        struct Border *border;
  45.  *
  46.  * INPUTS:    void    **memheadptr;    pointer to chained-memory head
  47.  *        SHORT    xsize;        total width in pixels
  48.  *        SHORT    ysize;        total height in pixels
  49.  *
  50.  * DESCRIPTION: Allocate and initialize a Border structure.
  51.  *        If xsize and ysize are both strictly positive, the five
  52.  *        coordinates for the border are set up as well.
  53.  *
  54.  *        Note: the draw mode and colours are set to JAM1 and 1, 0.
  55.  *
  56.  *        If memheadptr is non-NULL, chainAllocMem is used and you
  57.  *        should use chainFreeMem eventually to free the memory;
  58.  *        otherwise AllocMem is used and you must FreeMem on each
  59.  *        separately allocated component.
  60.  *
  61.  * RESULTS:    Returns pointer to Border, or NULL.
  62.  *
  63.  * SEE ALSO:    chainAllocMem, chainFreeMem
  64.  */
  65.  
  66. /*
  67.  * NAME:    gimmeImage
  68.  *
  69.  * SYNOPSIS:    image = gimmeImage( memheadptr, depth, width, height );
  70.  *        struct Image *image;
  71.  *
  72.  * INPUTS:    void    **memheadptr;        pointer to chained-memory head
  73.  *        SHORT    depth;            number of bit-planes for image
  74.  *        SHORT    width;            width of image in pixels
  75.  *        SHORT    height;         height of image in pixels
  76.  *
  77.  * DESCRIPTION: Allocate and initialize an Image structure.
  78.  *        If depth, width and height are all non-zero, sufficient
  79.  *        contiguous chip memory is allocated for the image data;
  80.  *        the pointer is stored in the image's ImageData field.
  81.  *
  82.  *        If memheadptr is non-NULL, chainAllocMem is used and you
  83.  *        should use chainFreeMem eventually to free the memory;
  84.  *        otherwise AllocMem is used and you must FreeMem on each
  85.  *        separately allocated component.
  86.  *
  87.  * RESULTS:    Returns pointer to Image, or NULL.
  88.  *
  89.  * SEE ALSO:    chainAllocMem, chainFreeMem
  90.  */
  91.  
  92. /*
  93.  * NAME:    gimmeIntuiText
  94.  *
  95.  * SYNOPSIS:    itext = gimmeIntuiText( memheadptr, s, textattr, width );
  96.  *        struct IntuiText *itext;
  97.  *
  98.  * INPUTS:    void    **memheadptr;        pointer to chained-memory head
  99.  *        UBYTE    *s;            text string
  100.  *        struct TextAttr *textattr;  pointer to font, or NULL
  101.  *        SHORT    width;            total width; for optional centering
  102.  *
  103.  * DESCRIPTION: Allocate and initialize a IntuiText structure.
  104.  *        The textattr can be NULL to use the default font.
  105.  *
  106.  *        NOTE: width is "optional":
  107.  *        if width is positive, then the string is centered in the
  108.  *        field that is width pixels wide.
  109.  *
  110.  *        Note: the draw mode and colours are set to JAM2 and 1, 0.
  111.  *
  112.  *        If memheadptr is non-NULL, chainAllocMem is used and you
  113.  *        should use chainFreeMem eventually to free the memory;
  114.  *        otherwise AllocMem is used and you must FreeMem on each
  115.  *        separately allocated component.
  116.  *
  117.  * RESULTS:    Returns pointer to IntuiText, or NULL.
  118.  *
  119.  * SEE ALSO:    chainAllocMem, chainFreeMem
  120.  */
  121.  
  122. /*
  123.  * NAME:    deadKeyConvert
  124.  *
  125.  * REQUISITES:    struct ConsoleDevice *ConsoleDevice;    properly initialized
  126.  *
  127.  * SYNOPSIS:    len = deadKeyConvert( imsg, buf, bufsize, keymap );
  128.  *        SHORT len;
  129.  *
  130.  * INPUTS:    struct IntuiMessage *imsg;    pointer to Intuition message
  131.  *        UBYTE    *buf;            address of a buffer
  132.  *        USHORT    bufsize;        size of the buffer "buf"
  133.  *        struct KeyMap    *keymap;    pointer to a KeyMap, or NULL
  134.  *
  135.  * DESCRIPTION: Takes an Intuition RAWKEY message and processes it.
  136.  *        The result will be "cooked" keys and key conversions placed
  137.  *        in the buffer "buf".
  138.  *
  139.  *        NOTE: you must have a global variable named ConsoleDevice,
  140.  *        declared as a "struct ConsoleDevice *", already initialized by
  141.  *        extracting the "library" pointer from the console.device
  142.  *        with code similar to the following:
  143.  *            struct IOStdReq ioreq;
  144.  *            err = OpenDevice("console.device", <unit-no>, &ioreq, 0L);
  145.  *            { check for error }
  146.  *            ConsoleDevice = (struct ConsoleDevice *) ioreq.io_Device;
  147.  *
  148.  *        Also, some versions of the Axtec C "functions.h" file have
  149.  *        a bug: it declares the function "ConsoleDevice()" which
  150.  *        is non-existant and that line should be deleted.
  151.  *        Note: this is *very* similar to the DeadKeyConvert() function
  152.  *        from the Amiga Enhancer Manual.
  153.  *
  154.  * RESULTS:    Returns the actual number of characters put into the buffer
  155.  *        or -1 if the buffer overflowed
  156.  *        or -2 if the IntuiMessage is not of class RAWKEY
  157.  *        or -3 if parameters are invalid (if checking is done)
  158.  */
  159.  
  160. /*
  161.  * NAME:    chainAllocMem
  162.  *
  163.  * SYNOPSIS:    memptr = chainAllocMem( headptr, size, type );
  164.  *        void *memptr;
  165.  *
  166.  * INPUTS:    void    **headptr;    ptr to the memory-chain head
  167.  *        ULONG    size;        size of desired memory
  168.  *        ULONG    flags;        type of memory ala AllocMem()
  169.  *
  170.  * DESCRIPTION: Allocate requested memory and possibly chain it to *headptr.
  171.  *
  172.  *        NOTE: if headptr is non-NULL, the chain head pointer MUST be
  173.  *        initialized to NULL before its first use, and
  174.  *        the memory returned must be freed by chainFreeMem only!!
  175.  *
  176.  *        NOTE: if headptr is NULL, then a normal AllocMem() is done
  177.  *        and absolutely no chaining occurs and you are responsible
  178.  *        for freeing the memory with a FreeMem(),
  179.  *
  180.  * RESULTS:    Returns pointer to requested chunk of memory, or NULL.
  181.  *        Note that *headptr is updated if headptr is a valid pointer.
  182.  *
  183.  * SEE ALSO:    chainFreeMem, AllocMem, linkChainMem
  184.  */
  185.  
  186. /*
  187.  * NAME:    chainFreeMem
  188.  *
  189.  * SYNOPSIS:    chainFreeMem( head );
  190.  *
  191.  * INPUTS:    void    *head;            head of memory-chain to be freed
  192.  *
  193.  * DESCRIPTION: Free all memory chained to this head (including the head)
  194.  *
  195.  *        NOTE: head must be NULL or altered by chainAllocMem only!
  196.  *
  197.  * SEE ALSO:    chainAllocMem, pluckChainMem
  198.  */
  199.  
  200. /*
  201.  * NAME:    linkChainMem
  202.  *
  203.  * SYNOPSIS:    err = linkChainMem( headptr, head );
  204.  *        short err;
  205.  *
  206.  * INPUTS:    void    **headptr;        ptr to memory-chain head
  207.  *        void    *head;            secondary chain head
  208.  *
  209.  * DESCRIPTION: Link secondary chain (pointed at by head) to the front of the
  210.  *        memory-chain (pointed at by *headptr), updating *headptr.
  211.  *
  212.  *        NOTE: head and the head pointed at by headptr must be NULL or
  213.  *        altered by chainAllocMem only!
  214.  *
  215.  * RESULTS:    Non-zero on error. Note that *headptr may be updated.
  216.  *
  217.  * SEE ALSO:    chainAllocMem
  218.  */
  219.  
  220. /*
  221.  * NAME:    pluckChainMem
  222.  *
  223.  * SYNOPSIS:    err = pluckChainMem( headptr, mem );
  224.  *        short err;
  225.  *
  226.  * INPUTS:    void    **headptr;        ptr to memory-chain head
  227.  *        void    *mem;            actual pointer to memory chunk
  228.  *
  229.  * DESCRIPTION: Search for the "mem" entry in the memory-chain list pointed at
  230.  *        by headptr; if it is in the list, unlink it and free the memory,
  231.  *        otherwise it will not be freed so that memory lists are not
  232.  *        corrupted.
  233.  *        NOTE: mem must be a "real" pointer returned by chainAllocMem.
  234.  *
  235.  *        NOTE: the head pointed at by headptr must be NULL or
  236.  *        altered by chainAllocMem only!
  237.  *
  238.  * RESULTS:    Non-zero on error, eg. headptr is NULL.
  239.  *        Note that *headptr may be updated.
  240.  *        If successful, the memory "mem" is freed and therefore unusable.
  241.  *
  242.  * SEE ALSO:    chainAllocMem, chainFreeMem
  243.  */
  244.  
  245. /*
  246.  * NAME:    gimmeMenu
  247.  *
  248.  * SYNOPSIS:    menu = gimmeMenu( memheadptr, left, width, name, flags );
  249.  *        struct Menu *menu;
  250.  *
  251.  * INPUTS:    void    **memheadptr;    pointer to chained-memory head
  252.  *        SHORT    left;        left offset in pixels
  253.  *        SHORT    width;        total width in pixels, or -1
  254.  *        UBYTE    *name;        name for menu
  255.  *        ULONG    flags;        Menu flags
  256.  *
  257.  * DESCRIPTION: Allocate and initialize a Menu structure.
  258.  *        Width should include room for a checkmark if necessary.
  259.  *        If width is -1 (negative), a feeble attempt at calculating
  260.  *        a width is made (9 pixels per character).
  261.  *
  262.  *        If memheadptr is non-NULL, chainAllocMem is used and you
  263.  *        should use chainFreeMem eventually to free the memory;
  264.  *        otherwise AllocMem is used and you must FreeMem on each
  265.  *        separately allocated component.
  266.  *
  267.  * RESULTS:    Returns pointer to Menu, or NULL.
  268.  *
  269.  * SEE ALSO:    chainAllocMem, chainFreeMem, gimmeMenuItem
  270.  */
  271.  
  272. /*
  273.  * NAME:    gimmeMenuItem
  274.  *
  275.  * REQUISITES:    struct GfxBase *GfxBase;    properly initialized - but only if
  276.  *                          text && height == -1  && !textattr
  277.  *
  278.  * SYNOPSIS:    item = gimmeMenuItem( memheadptr, left, width, height,
  279.  *                    command, name, textattr, flags );
  280.  *        struct MenuItem *item;
  281.  *
  282.  * INPUTS:    void    **memheadptr;        pointer to chained-memory head
  283.  *        SHORT    left;            left offset in pixels
  284.  *        SHORT    width;            total width in pixels, or -1
  285.  *        SHORT    height;         total height in pixels, or -1
  286.  *        BYTE    command;        Command byte, if COMMSEQ flag set
  287.  *        UBYTE    *name;            name for menu item
  288.  *        struct TextAttr *textattr;  pointer to font, or NULL
  289.  *        ULONG    flags;            MenuItem flags
  290.  *
  291.  * DESCRIPTION: Allocate and initialize a MenuItem structure.
  292.  *        If ITEMTEXT flag set, then an IntuiText structure is created
  293.  *        using the name and textattr (using INVERSVID drawing mode);
  294.  *        otherwise:
  295.  *            treat "(struct Image *)name" as primary image
  296.  *            if HIGHIMAGE set, then treat
  297.  *            "(struct Image *)textattr" as secondary image
  298.  *        In either case, if width (and/or height) is -1 (negative)
  299.  *        a suitable width (and/or height) is calculated. Further,
  300.  *        if the CHECKIT or COMMSEQ flags are set, then CHECKWIDTH or
  301.  *        COMMWIDTH respectively is added in to the calculated width
  302.  *        (not LOWCHECKWIDTH nor LOWCOMMWIDTH since I can't tell the
  303.  *        resolution and besides, no one really uses lo-res do they? :-)
  304.  *
  305.  *        NOTE: chainAllocMem is used and you
  306.  *        should use chainFreeMem eventually to free the memory;
  307.  *
  308.  * RESULTS:    Returns pointer to MenuItem, or NULL.
  309.  *
  310.  * SEE ALSO:    chainAllocMem, chainFreeMem, gimmeMenu
  311.  */
  312.  
  313. /*
  314.  * NAME:    addMenuItem
  315.  *
  316.  * SYNOPSIS:    menucode = addMenuItem( menu, item, positem, possub,
  317.  *                        numitem, myflags );
  318.  *        ULONG menucode;
  319.  *
  320.  * INPUTS:    struct Menu    *menu;        menu to which to add MenuItem
  321.  *        struct MenuItem *item;        item (or subitem) to add
  322.  *        SHORT        positem;    position of item, or -1
  323.  *        SHORT        possub;     position of subitem, or -1
  324.  *        SHORT        numitem;    number of (sub)items to add, or -1
  325.  *        ULONG        myflags;    flags for this routine
  326.  *
  327.  * DESCRIPTION: Add a (list of) MenuItem to a Menu as an item or a subitem,
  328.  *        depending on the flags.
  329.  *        If the subitem-flag is set in myflags, then positem is used to
  330.  *        locate a MenuItem to which "item" is to be added as a subitem;
  331.  *         NOTE: in this case a MenuItem must already exist in the menu.
  332.  *
  333.  *        Actually add numitem MenuItems from a list starting with "item",
  334.  *        where a numitem of -1 means all the MenuItems in the list.
  335.  *        Either positem or possub may be -1 (ie. negative) which means
  336.  *        the end of the list; otherwise use normal menu(item) position
  337.  *        numbers, ie. 0 means the first one, 1 means the second, etc.
  338.  *
  339.  *        The flags (see gimmelib/menustuff.h) dictate other options,
  340.  *        such as automatic adjusting of top edges to compensate visually
  341.  *        for the insertion of the menuitems (visually) in the middle or
  342.  *        at the end of the menu.
  343.  *        Note: the Intuition menucode depends on the physical position
  344.  *        of the menuitem in the menu's chain (not the visual position).
  345.  *
  346.  *        NOTE: this routine should only be used on a menustrip that is
  347.  *        not attached to a window or guaranteed not to be actively used
  348.  *        by Intuition (eg. by using the MENUVERIFY flag).
  349.  *
  350.  * RESULTS:    Returns menucode corresponding to position of (sub)item,
  351.  *        or MENUNULL on error.
  352.  *
  353.  * SEE ALSO:    gimmeMenuItem, gimmeMenu, addMenu
  354.  */
  355.  
  356. /*
  357.  * NAME:    addMenu
  358.  *
  359.  * SYNOPSIS:    menucode = addMenu( menuptr, menu, posmenu, nummenu, myflags );
  360.  *        ULONG menucode;
  361.  *
  362.  * INPUTS:    struct Menu    **menuptr;  pointer to menu ptr on which to add
  363.  *        struct Menu    *menu;        menu to add
  364.  *        SHORT        posmenu;    position of menu, or -1
  365.  *        SHORT        nummenu;    number of menus to add, or -1
  366.  *        ULONG        myflags;    flags for this routine
  367.  *
  368.  * DESCRIPTION: Add nummenu Menus to a menustrip starting with "menu",
  369.  *        where a nummenu of -1 means all the Menus in the list.
  370.  *
  371.  *        A posmenu of -1 (ie. negative) means the end of the list;
  372.  *        otherwise use normal menu position numbers, ie. 0 means the
  373.  *        first one, 1 means the second, etc.
  374.  *
  375.  *        NOTE: menuptr can point at a NULL pointer (ie *menuptr == NULL)
  376.  *        which means that a "new" menu is begun with "menu".
  377.  *
  378.  *        The flags (see gimmelib/menustuff.h) dictate other options,
  379.  *        such as automatic adjusting of left edges to compensate for
  380.  *        the insertion of the menus (visually) in the middle or at the
  381.  *        end of the menustrip.
  382.  *        Note: the Intuition menucode depends on the physical position
  383.  *        of the menu in the menustrip's chain (not the visual position).
  384.  *
  385.  *        NOTE: this routine should only be used on a menustrip that is
  386.  *        not attached to a window or guaranteed not to be actively used
  387.  *        by Intuition (eg. by using the MENUVERIFY flag).
  388.  *
  389.  * RESULTS:    Returns menucode corresponding to position of menu,
  390.  *        or MENUNULL on error.
  391.  *
  392.  * SEE ALSO:    gimmeMenu, gimmeMenuItem, addMenuItem
  393.  */
  394.  
  395. /*
  396.  * NAME:    removeMenuItem
  397.  *
  398.  * SYNOPSIS:    item = removeMenuItem( menu, item, positem, possub,
  399.  *                        numitem, myflags );
  400.  *        strut MenuItem *item;
  401.  *
  402.  * INPUTS:    struct Menu    *menu;        menu from which to remove MenuItem
  403.  *        struct MenuItem *item;        item (or subitem) to remove, or NULL
  404.  *        SHORT        positem;    position of item, or -1
  405.  *        SHORT        possub;     position of subitem, or -1
  406.  *        SHORT        numitem;    #(sub)items to remove, or -1
  407.  *        ULONG        myflags;    flags for this routine
  408.  *
  409.  * DESCRIPTION: Remove a (list of) MenuItem to a Menu as an item or a subitem,
  410.  *        depending on the flags.
  411.  *        If the subitem-flag is set in myflags, then positem is used to
  412.  *        locate a MenuItem from which "item" is to be removed as a
  413.  *        subitem; NOTE: in this case a MenuItem must already exist in
  414.  *        the menu.
  415.  *
  416.  *        If item is non-NULL (ie. you have an actual MenuItem address):
  417.  *        actually remove numitem MenuItems from a list starting with
  418.  *        "item", where numitem of -1 means all the MenuItems in the list;
  419.  *        in this case, positem and possub are ignored.
  420.  *
  421.  *        Otherwise (if item is NULL):
  422.  *        find the appropriate item [as specified by positem, and possub
  423.  *        if the subitem-flag is set] and then actually remove numitem
  424.  *        MenuItems starting with the found item, where numitem of -1
  425.  *        means all the MenuItems in the list.
  426.  *        Either positem or possub may be -1 (ie. negative) which means
  427.  *        the end of the list; otherwise use normal menu(item) position
  428.  *        numbers, ie. 0 means the first one, 1 means the second, etc.
  429.  *
  430.  *        The flags (see gimmelib/menustuff.h) dictate other options,
  431.  *        such as automatic adjusting of top edges to compensate for the
  432.  *        removal of the menuitems (effects visual offsets in the menu).
  433.  *
  434.  *        NOTE: this routine should only be used on a menustrip that is
  435.  *        not attached to a window or guaranteed not to be actively used
  436.  *        by Intuition (eg. by using the MENUVERIFY flag).
  437.  *
  438.  * RESULTS:    Returns pointer to the (list of) MenuItem removed,
  439.  *        or NULL on error.
  440.  *
  441.  * SEE ALSO:    addMenuItem, addMenu, removeMenu
  442.  */
  443.  
  444. /*
  445.  * NAME:    removeMenu
  446.  *
  447.  * SYNOPSIS:    menu = removeMenu( menuptr, menu, posmenu, nummenu, myflags );
  448.  *        struct Menu *menu;
  449.  *
  450.  * INPUTS:    struct Menu    **menuptr;  pointer to menu ptr on which to add
  451.  *        struct Menu    *menu;        menu to remove, or NULL
  452.  *        SHORT        posmenu;    position of menu, or -1
  453.  *        SHORT        nummenu;    number of menus to remove, or -1
  454.  *        ULONG        myflags;    flags for this routine
  455.  *
  456.  * DESCRIPTION: Remove a (list of) Menu from a menustrip.
  457.  *
  458.  *        If menu is non-NULL (ie. you have an actual Menu address):
  459.  *        actually remove nummenu Menus from a list starting with
  460.  *        "menu", where nummenu of -1 means all the Menus in the list;
  461.  *        in this case, posmenu is ignored.
  462.  *
  463.  *        Otherwise (if menu is NULL):
  464.  *        find the appropriate menu [as specified by posmenu], and then
  465.  *        actually remove nummenu Menus starting with the found menu,
  466.  *        where nummenu of -1 means all the Menus in the list.
  467.  *        A posmenu of -1 (ie. negative) means the end of the list;
  468.  *        otherwise use normal menu(item) position numbers,
  469.  *        ie. 0 means the first one, 1 means the second, etc.
  470.  *
  471.  *        The flags (see gimmelib/menustuff.h) dictate other options,
  472.  *        such as automatic adjusting of left edges to compensate for
  473.  *        the removal of the menus (visually) in the middle or at the
  474.  *        end of the menustrip.
  475.  *
  476.  *        NOTE: this routine should only be used on a menustrip that is
  477.  *        not attached to a window or guaranteed not to be actively used
  478.  *        by Intuition (eg. by using the MENUVERIFY flag).
  479.  *
  480.  * RESULTS:    Returns pointer to the (list of) MenuItem removed,
  481.  *        or NULL on error.
  482.  *
  483.  * SEE ALSO:    addMenu, addMenuItem, removeMenuItem
  484.  */
  485.  
  486. /*
  487.  * NAME:    adjustMenuItems
  488.  *
  489.  * SYNOPSIS:    err = adjustMenuItems( item, stop, topedge, mepos, myflags );
  490.  *        short err;
  491.  *
  492.  * INPUTS:    struct MenuItem *item;        item at which to start
  493.  *        struct MenuItem *stop;        first item not to alter, or NULL
  494.  *        SHORT        topedge;    topedge for first menu item
  495.  *        SHORT        mepos;        pos of 1st item (for MutualExclude)
  496.  *        ULONG        myflags;    flags for this routine
  497.  *
  498.  * DESCRIPTION: Adjust the TopEdge and/or MutualExclude fields of a list of
  499.  *        MenuItems, depending on the flags.
  500.  *
  501.  *        Starting with "item" the adjustment is done for the entire list,
  502.  *        OR until (but not including) "stop" is reached,
  503.  *        OR only from "stop" until the end of the list
  504.  *        -- all according to the flags (see gimmelib/menustuff.h).
  505.  *
  506.  *        The topedge and mutualexlude options are independant (and have
  507.  *        separate flags), so you can mix and match when either one is
  508.  *        done in a single call [eg. adjust topedges until "past" and
  509.  *        mutualexcludes only from "past" onwards].
  510.  *
  511.  *        NOTE: this routine should only be used on a menustrip that is
  512.  *        not attached to a window or guaranteed not to be actively used
  513.  *        by Intuition (eg. by using the MENUVERIFY flag).
  514.  *
  515.  * RESULTS:    Returns non-zero on error.
  516.  *
  517.  * SEE ALSO:    gimmeMenuItem, addMenuItem, gimmeMenu, addMenu
  518.  */
  519.  
  520. /*
  521.  * NAME:    adjustMenuLefts
  522.  *
  523.  * SYNOPSIS:    err = adjustMenuLefts( menu, stop, leftedge, myflags );
  524.  *        short err;
  525.  *
  526.  * INPUTS:    struct Menu *menu;    menu at which to start
  527.  *        struct Menu *stop;    first menu not to alter, or NULL
  528.  *        SHORT        leftedge;    leftedge for first menu given
  529.  *        ULONG        myflags;    flags for this routine
  530.  *
  531.  * DESCRIPTION: Adjust the LeftEdge field of a list of Menus, starting with
  532.  *        leftedge and incremented using the widths of the menus.
  533.  *
  534.  *        Starting with "menu" the adjustment is done for the entire list,
  535.  *        OR until (but not including) "stop" is reached -- according to
  536.  *        the flags (see gimmelib/menustuff.h).
  537.  *
  538.  *        NOTE: this routine should only be used on a menustrip that is
  539.  *        not attached to a window or guaranteed not to be actively used
  540.  *        by Intuition (eg. by using the MENUVERIFY flag).
  541.  *
  542.  * RESULTS:    Returns non-zero on error.
  543.  *
  544.  * SEE ALSO:    gimmeMenuItem, addMenuItem, gimmeMenu, addMenu
  545.  */
  546.  
  547. /*
  548.  * NAME:    gimmeMessage
  549.  *
  550.  * SYNOPSIS:    msg = gimmeMessage( size, replyport );
  551.  *        struct Message *msg;
  552.  *
  553.  * INPUTS:    ULONG        size;        size of your message struct
  554.  *        struct MsgPort    *replyport;    ptr to a reply port, or NULL
  555.  *
  556.  * DESCRIPTION: Allocate memory for an [extended] message struct,
  557.  *        initializing the Node, Length and ReplyPort [enough to
  558.  *        do a PutMsg() immediately].
  559.  *        Node type set to NT_FREEMSG for consistency.
  560.  *
  561.  *        NOTE: size must be passed as a ULONG, *not* a short.
  562.  *
  563.  * RESULTS:    Returns pointer to an [extended] message struct of the
  564.  *        specified size, or NULL on failure.
  565.  *
  566.  * SEE ALSO:    getRidOfMessage
  567.  */
  568.  
  569. /*
  570.  * NAME:    getRidOfMessage
  571.  *
  572.  * SYNOPSIS:    err = getRidOfMessage( msg );
  573.  *        short err;
  574.  *
  575.  * INPUTS:    struct Message    *msg;        pointer to initialized Message
  576.  *
  577.  * DESCRIPTION: Free the [extended] message struct, using its Length field.
  578.  *
  579.  * RESULTS:    Returns non-zero on error.
  580.  *
  581.  * SEE ALSO:    gimmeMessage
  582.  */
  583.  
  584. /*
  585.  * NAME:    gimmePicture
  586.  *
  587.  *        #include <gimmelib/picture.h>
  588.  *
  589.  * SYNOPSIS:    pic = gimmePicture( filename, myflags );
  590.  *        PICTURE *pic;
  591.  *
  592.  * INPUTS:    UBYTE    *filename;        name of iff ilbm file
  593.  *        ULONG    myflags;        flags for the routine
  594.  *
  595.  * DESCRIPTION: Read a picture (IFF/ILBM) from the specified file.
  596.  *        Create and initialize a PICTURE structure for the picture.
  597.  *        The flags specify whether chip memory for the bitplanes
  598.  *        should be allocated contiguously or sequentially or either;
  599.  *        these flags are the same as those used by gimmeBitPlanes,
  600.  *        and are defined in <gimmelib/bitplane.h>.
  601.  *        If possible, an error message is printed if anything goes
  602.  *        wrong -- it is safe to call this function from a (sub)task
  603.  *        that has no CLI window.
  604.  *
  605.  *        Note: all allocated memory, including the PICTURE struct itself,
  606.  *        is chained and the header is stored in the PICTURE's memhead
  607.  *        field, which is used by getRidOfPicture to deallocate memory.
  608.  *        You should use getRidOfPicture to free all the memory allocated
  609.  *        by this routine.
  610.  *
  611.  * RESULTS:    Returns pointer to an initialized PICTURE, or NULL on error.
  612.  *
  613.  * SEE ALSO:    getRidOfPicture
  614.  */
  615.  
  616. /*
  617.  * NAME:    getRidOfPicture
  618.  *
  619.  * SYNOPSIS:    err = getRidOfPicture( picture );
  620.  *        short err;
  621.  *
  622.  * INPUTS:    PICTURE   *picture;        pointer to PICTURE
  623.  *
  624.  * DESCRIPTION: De-allocate a PICTURE structure that was dynamically
  625.  *        allocated by gimmePicture.
  626.  *
  627.  * RESULTS:    Returns non-zero on error.
  628.  *
  629.  * SEE ALSO:    gimmePicture
  630.  */
  631.  
  632. /*
  633.  * NAME:    positionPicture
  634.  *
  635.  * SYNOPSIS:    err = positionPicture( rp, myflags, pic, minterm, x, y );
  636.  *        short err;
  637.  *
  638.  * INPUTS:    struct RastPort *rp;        rastport in which to place it
  639.  *        ULONG        myflags;    flags for the routine
  640.  *        PICTURE     *pic;        picture to be placed/removed
  641.  *        SHORT        minterm;    how to blit the picture
  642.  *        SHORT        x, y;        offsets for placing picture
  643.  *
  644.  * DESCRIPTION: Position a picture's image into a rastport using the blitter.
  645.  *        The rastport should NOT be a window's rastport, because of
  646.  *        layers associated with windows that are bypassed here.
  647.  *        The flags modify the interpretation of the x and y coordinates
  648.  *        so that the x and y values can specify the centre or any corner
  649.  *        pixel positions; see gimmelib/postext.h for the actual flags.
  650.  *        The minterm determines how the picture's image (bitmap) will
  651.  *        be blitted into the screen's rastport; see gimmelib/minterm.h
  652.  *        for some common minterms.
  653.  *
  654.  *        NOTE: clipping is done so that you can safely position part or
  655.  *        all of the picture outside of the rastport's boundaries so that
  656.  *        the remaining portion (if any) is visible.
  657.  *
  658.  * RESULTS:    Returns non-zero on error.
  659.  *
  660.  * SEE ALSO:    gimmePicture, getRidOfPicture
  661.  */
  662.  
  663. /*
  664.  * NAME:    usePictureColors
  665.  *
  666.  * SYNOPSIS:    err = usePictureColors( pic, screen );
  667.  *        short err;
  668.  *
  669.  * INPUTS:    PICTURE     *pic;        use this picture's colors
  670.  *        struct Screen    *screen;    screen to be affected
  671.  *
  672.  * DESCRIPTION: Set a screen's colors to those of a picture.
  673.  *
  674.  * RESULTS:    Returns non-zero on error.
  675.  *
  676.  * SEE ALSO:    gimmePicture, getRidOfPicture
  677.  */
  678.  
  679. /*
  680.  * NAME:    positionText
  681.  *
  682.  * SYNOPSIS:    maxrastlen = positionText( rp, myflags, s, num, x, y );;
  683.  *        SHORT maxrastlen;
  684.  *
  685.  * INPUTS:    struct RastPort *rp;    pointer to rastport to draw into
  686.  *        ULONG    myflags;    routine flags controlling position
  687.  *        UBYTE    *s;        pointer to string to display, or NULL
  688.  *        LONG    num;        number to display (or 0L if not used)
  689.  *        SHORT    x, y;        coordinates used in displaying text,
  690.  *                      interpreted according to flags
  691.  *
  692.  * DESCRIPTION: Displays a string using the coordinates (x, y).
  693.  *        The string displayed is: if s is NULL, "num" is converted
  694.  *        to a string, otherwise the string "s" is used.
  695.  *        The current font, pen colours and draw-mode of the rastport
  696.  *        are used.
  697.  *        The type of coordinates can be specified in the <flags>
  698.  *        individually for x/y (see gimmelib/postext.h for flag names):
  699.  *        - flags for x: left, right and centre.
  700.  *        - flags for y: top, bottom, centre, baseline, centrebase.
  701.  *        For example, specifying the centre-x flag will cause the
  702.  *        x coordinate to be used as the centre of the text to be
  703.  *        displayed.
  704.  *        NOTE: centre-y means the centre of the character's height,
  705.  *        whereas centrebase-y means the centre of the top of the
  706.  *        character to its baseline. Since most of a character
  707.  *        appears above the baseline, this may be more desirable than
  708.  *        centre-y on certain fonts.
  709.  *
  710.  *        Note: normally when text is displayed using the system's
  711.  *        Text() function, the coordinates specified are the LEFT-x
  712.  *        and BASELINE-y.
  713.  *
  714.  *        If the y-upwards or y-downwards control flags are specified,
  715.  *        then the text is written vertically (eg. a label for a y-axis).
  716.  *        Note "upwards" means rotated 90 degrees counter-clockwise,
  717.  *        similarly "downwards" is clockwise (as viewed from your seat).
  718.  *        In these 2 cases, the meaning of the flags are changed slightly:
  719.  *        the x-flags are applied to the y-coordinate, and the y-flags are
  720.  *        applied to the x-coordinate. The way to picture this is like so:
  721.  *        if you look at your vertical text so that is horizontal (normal)
  722.  *        then how would you apply the flags? But since the vertical text
  723.  *        does get rotated 90 degrees, the x and y coordinates really
  724.  *        apply to the y and x coordinates relative to the normal text.
  725.  *        eg. the baseline of the text is now an offset in the x-direction
  726.  *        because the text is sideways.
  727.  *        NOTE: currently any portion of vertical text (JAM2 or otherwise)
  728.  *        that is colour 0 does NOT get rendered in the rastport.
  729.  *        Note: the x-thicken control flag only works in conjunction with
  730.  *        vertical text.
  731.  *        Note: vertical text does NOT take layers into account.
  732.  *
  733.  * RESULTS:    Returns the maximum possible length in pixels that the
  734.  *        number/string could occupy in the current given rastport,
  735.  *        or a negative number on error (eg. incorrect parameters).
  736.  */
  737.  
  738. /*
  739.  * NAME:    gimmeAutoRequest
  740.  *
  741.  * SYNOPSIS:    result = gimmeAutoRequest( window, s, textattr );
  742.  *        SHORT result;
  743.  *
  744.  * INPUTS:    struct Window    *window;    window, or NULL for default screen
  745.  *        UBYTE        *s;        main text string for requester
  746.  *        struct TextAttr *textattr;  pointer to font type, or NULL
  747.  *
  748.  * DESCRIPTION: Put up an auto requester in the window (or screen if window
  749.  *        is NULL).
  750.  *        Use default font if textattr is NULL.
  751.  *
  752.  *        Note: If you wish to change the default positive/negative
  753.  *        gadgets' text, you can alter the pointers which are extern'd in
  754.  *        gimmelib/requester.h, to which you are referred.
  755.  *        The defaults can be restored by assigning GAR_POSTEXT and
  756.  *        GAR_NEGTEXT to the respective pointers.
  757.  *        Caution: if you play around with these pointers in your program,
  758.  *        you must not have more than one task within the same process
  759.  *        space manipulating these pointers simultaneously.
  760.  *
  761.  * RESULTS:    Returns TRUE or FALSE, ala AutoRequest(), according to the
  762.  *        user's selection.
  763.  */
  764.  
  765. /*
  766.  * NAME:    gimmeRequester
  767.  *
  768.  * SYNOPSIS:    req = gimmeRequester( memheadptr, left, top, width, height,
  769.  *                    backfill, gplist, s, textattr, flags );
  770.  *        struct Requester *req;
  771.  *
  772.  * INPUTS:    void    **memheadptr;        pointer to chained-memory head
  773.  *        SHORT    left;            left offset in pixels
  774.  *        SHORT    top;            top offset in pixels
  775.  *        SHORT    width;            total width in pixels, or -1
  776.  *        SHORT    height;         total height in pixels, or -1
  777.  *        UBYTE    backfill;        color to fill in back of requester
  778.  *        struct Gadget    *gplist;    first of a list of gadgets
  779.  *        UBYTE    *s;            main text string, or NULL
  780.  *        struct TextAttr *textattr;  pointer to font, or NULL
  781.  *        ULONG    flags;            Requester flags
  782.  *
  783.  * DESCRIPTION: Allocate and initialize a Requester structure,
  784.  *        including a border just inside the edge of the requester
  785.  *        in the complement of the backfill colour.
  786.  *        Note: this routine succeeds even if no border was allocated
  787.  *        (check gp->GadgetRender for a non-NULL value if you want to
  788.  *        be sure that a border was allocated).
  789.  *        If you want to remove the border, do something similar to this:
  790.  *            pluckChainMem( memheadptr, req->ReqBorder );
  791.  *            req->ReqBorder = NULL;
  792.  *
  793.  *        The requester background is filled with the backfill color.
  794.  *        The main text string pointed at by "s" is put in its own
  795.  *        (allocated) IntuiText struct.
  796.  *        If width is non-positive, then a suitable width is calculated
  797.  *        based on the given text, font and gadgets.
  798.  *        If height is non-positive, then a suitable height is calculated
  799.  *        based on the given text, font and gadgets.
  800.  *        Note: in either of these cases, gadget Borders or alternate
  801.  *        images are not checked in calculating sufficient sizes.
  802.  *
  803.  *        The textattr can be NULL to use the default font.
  804.  *        The linked list of gadget(s) is attached to the requester;
  805.  *        remember that at least one gadget must have the ENDGADGET flag
  806.  *        set so that the requester can be made to go away.
  807.  *        Note that you might have to adjust the gadgets' back colours
  808.  *        to match the backfill colour yourself if JAM2 modes are used.
  809.  *        The flags are set in the requester's Flags field.
  810.  *
  811.  *        The allocated memory is chained to the memory chain pointed
  812.  *        at by memheadptr using chainAllocMem.
  813.  *        Eventually chainFreeMem should be called on the memhead.
  814.  *
  815.  * RESULTS:    Returns pointer to requester, or NULL.
  816.  *        Note: the requester is NOT added to a window.
  817.  *
  818.  * SEE ALSO:    chainAllocMem, chainFreeMem, gimmeStringInfo
  819.  */
  820.  
  821. /*
  822.  * NAME:    gimmeNewScreen
  823.  *
  824.  * SYNOPSIS:    ns = gimmeNewScreen( modes, type, depth, title, textattr );
  825.  *        struct NewScreen *ns;
  826.  *
  827.  * INPUTS:    ULONG    modes;            new screen ViewMode flags
  828.  *        ULONG    type;            new screen Type (eg CUSTOMSCREEN)
  829.  *        SHORT    depth;            depth to make screen
  830.  *        UBYTE    *title;         title string
  831.  *        struct TextAttr *textattr;  pointer to font, or NULL
  832.  *
  833.  * DESCRIPTION: Allocate and initialize a NewScreen structure.
  834.  *        Width and height taken from WorkBench screen (however, if
  835.  *        you want to find out the height, eg for windows, you must
  836.  *        wait until you open the screen and then check the Height
  837.  *        field in the Screen structure).
  838.  *        Note: this routine assumes an upper width limit of 350 for
  839.  *        lo-res screens, and adjusts the width taken from GfxBase
  840.  *        accordingly.
  841.  *
  842.  *        You can customize the NewScreen structure before opening
  843.  *        the screen.
  844.  *
  845.  * RESULTS:    Returns pointer to NewScreen structure, or NULL on error.
  846.  *
  847.  * SEE ALSO:    getRidOfNewScreen, gimmeScreen, getRidOfScreen
  848.  */
  849.  
  850. /*
  851.  * NAME:    getRidOfNewScreen
  852.  *
  853.  * SYNOPSIS:    err = getRidOfNewScreen( ns );
  854.  *        short err;
  855.  *
  856.  * INPUTS:    struct NewScreen    *ns;    pointer to NewScreen structure
  857.  *
  858.  * DESCRIPTION: De-allocates a NewScreen structure that was dynamically
  859.  *        allocated by gimmeNewScreen.
  860.  *
  861.  * RESULTS:    Returns non-zero on error.
  862.  *
  863.  * SEE ALSO:    gimmeNewScreen, gimmeScreen, gimmeScreenLazy, getRidOfScreen
  864.  */
  865.  
  866. /*
  867.  * NAME:    gimmeScreen
  868.  *
  869.  * SYNOPSIS:    screen = gimmeScreen( ns, windowptr, depth, IDCMPflags,
  870.  *                    winflags );
  871.  *        struct Screen *screen;
  872.  *
  873.  * INPUTS:    struct NewScreen    *ns;        ptr to initialized NewScreen
  874.  *        struct Window        **windowptr;    ptr to window ptr
  875.  *        SHORT            depth;        depth for window
  876.  *        ULONG            IDCMPflags;     IDCMP flags for window
  877.  *        ULONG            winflags;        flags for window
  878.  *
  879.  * DESCRIPTION: Open an Intuition screen.
  880.  *        If the NewScreen pointer "ns" in NULL, then a default NewScreen
  881.  *        structure is temporarily created, used and deleted.
  882.  *        If windowptr is non-NULL, a window with the given IDCMP and
  883.  *        window flags is opened on the screen; the pointer to this window
  884.  *        is placed where windowptr points to. The screen's titlebar will
  885.  *        be hidden behind the window if it is a backdrop window.
  886.  *        The window, if opened, will be the same width as the screen,
  887.  *        but one pixel shorter and placed down one pixel so that the
  888.  *        screen's titlebar is still accessible.
  889.  *        Note that the screen's titlebar may be partially visible.
  890.  *
  891.  *        Note: the depth parameter is only used if no NewScreen is
  892.  *        given, ie. if "ns" is NULL.
  893.  *
  894.  *        Note: when you close the screen with getRidOfScreen, you must
  895.  *        either close the window using getRidOfWindow on the window ptr
  896.  *        placed in *windowptr, OR pass this window ptr along to the
  897.  *        getRidOfScreen routine.
  898.  *
  899.  *        Note: this routine will fail if a window is asked for but
  900.  *        cannot be opened even though the screen opened (any allocated
  901.  *        memory will be freed and the screen closed before returning).
  902.  *
  903.  * RESULTS:    Returns a pointer to an open Intuition screen, or NULL if
  904.  *        anything went wrong. If windowptr is non-NULL, *windowptr will
  905.  *        be updated to contain a pointer to a window.
  906.  *
  907.  * SEE ALSO:    getRidOfNewScreen, gimmeScreenLazy, getRidOfScreen
  908.  */
  909.  
  910. /*
  911.  * NAME:    gimmeScreenLazy
  912.  *
  913.  * SYNOPSIS:    screen = gimmeScreenLazy( ns, windowptr, depth );
  914.  *        struct Screen *screen;
  915.  *
  916.  * INPUTS:    struct NewScreen    *ns;        ptr to initialized NewScreen
  917.  *        struct Window        **windowptr;    ptr to window ptr
  918.  *        SHORT            depth;        depth for window
  919.  *
  920.  * DESCRIPTION: Open an Intuition screen, and possibly a window.
  921.  *        This routine is a shortcut for using gimmeScreen, using
  922.  *        default IDCMP and window flags (see gimmelib/window.h) for
  923.  *        a backdrop window if windowptr in non-NULL.
  924.  *        Note that the screen titlebar may be partially visible.
  925.  *
  926.  *        Note: this routine will fail if a window is asked for but
  927.  *        cannot be opened even though the screen opened (any allocated
  928.  *        memory will be freed and the screen closed before returning).
  929.  *
  930.  * RESULTS:    Returns a pointer to an open Intuition screen, or NULL if
  931.  *        anything went wrong. If windowptr is non-NULL, *windowptr will
  932.  *        be updated to contain a pointer to a window.
  933.  *
  934.  * SEE ALSO:    gimmeNewScreen, gimmeScreen, getRidOfScreen
  935.  */
  936.  
  937. /*
  938.  * NAME:    getRidOfScreen
  939.  *
  940.  * SYNOPSIS:    err = getRidOfScreen( screen, window );
  941.  *        short err;
  942.  *
  943.  * INPUTS:    struct Screen    *screen;    pointer to Intuition screen
  944.  *        struct Window    *window;    pointer to window -- see note
  945.  *
  946.  * DESCRIPTION: Close a screen.
  947.  *        If window is non-NULL, close the window first.
  948.  *        NOTE: if window is specified, it SHOULD be the window ptr
  949.  *        returned by gimmeScreen where the window-ptr parameter
  950.  *        pointed to.
  951.  *
  952.  *        Note: does NOT call ClearMenuStrip() on the window.
  953.  *
  954.  * RESULTS:    Returns non-zero on error.
  955.  *
  956.  * SEE ALSO:    gimmeNewScreen, getRidOfNewScreen, gimmeScreen
  957.  */
  958.  
  959. /*
  960.  * NAME:    lowerScreen
  961.  *
  962.  * SYNOPSIS:    err = lowerScreen( screen, toheight );
  963.  *        short err;
  964.  *
  965.  * INPUTS:    struct Screen    *screen;    pointer to Intuition screen
  966.  *        SHORT    toheight;        height in pixels from top of view
  967.  *
  968.  * DESCRIPTION: Slide the screen down until top of screen is at the
  969.  *        desired height from the top of the viewing area.
  970.  *
  971.  * RESULTS:    Returns non-zero on error.
  972.  *
  973.  * SEE ALSO:    raiseScreen
  974.  */
  975.  
  976. /*
  977.  * NAME:    raiseScreen
  978.  *
  979.  * SYNOPSIS:    err = raiseScreen( screen, toheight );
  980.  *        short err;
  981.  *
  982.  * INPUTS:    struct Screen    *screen;    pointer to Intuition screen
  983.  *        SHORT    toheight;        height in pixels from top of view
  984.  *
  985.  * DESCRIPTION: Slides the screen up until top of screen is at the
  986.  *        desired height from the top of the viewing area.
  987.  *
  988.  * RESULTS:    Returns non-zero on error.
  989.  *
  990.  * SEE ALSO:    lowerScreen
  991.  */
  992.  
  993. /*
  994.  * NAME:    gimmeOneScroll
  995.  *
  996.  * SYNOPSIS:    gp = gimmeOneScroll( window, id, dirflags, myflags );
  997.  *        struct Gadget *gp;
  998.  *
  999.  * INPUTS:    struct Window    *window;    window for gadget, or NULL
  1000.  *        USHORT        id;        non-zero id for gadget
  1001.  *        ULONG        dirflags;   direction flags as per PropInfo
  1002.  *                          can be FREEVERT or FREEHORIZ
  1003.  *        ULONG        myflags;    flags for routine
  1004.  *
  1005.  * DESCRIPTION: Creates an initialized scroll-button (vertical or horizontal)
  1006.  *        placed near the corners of a window,
  1007.  *        leaving room for the sizing gadget (whether or not it is there).
  1008.  *        These are often used at the top/left and bottom/right ends
  1009.  *        of a scroll-bar to be used for incremental scrolling.
  1010.  *        If window is non-NULL, the gadget is further customized for
  1011.  *        the window (eg checks for GIMMEZEROZERO).
  1012.  *
  1013.  *        If all goes well, the head pointer to chained memory for the
  1014.  *        gadget and its other required structures is stored in the
  1015.  *        gp->UserData field. You must preserve this pointer!!
  1016.  *        If you need to use the UserData yourself, be sure to save
  1017.  *        gp->UserData somewhere safe after calling gimmeOneScroll.
  1018.  *        When you are done with the gadget you must ensure that the
  1019.  *        chained memory head pointer is restored into gp->UserData
  1020.  *        before you call getRidOfGadget.
  1021.  *
  1022.  * RESULTS:    Returns pointer to requested type of Gadget, or NULL.
  1023.  *        Note: The gadget is NOT added to the window.
  1024.  *
  1025.  * SEE ALSO:    getRidOfGadgets, gimmeScrollBar, gimmeFullScrollBar
  1026.  */
  1027.  
  1028. /*
  1029.  * NAME:    gimmeScrollBar
  1030.  *
  1031.  * SYNOPSIS:    gp = gimmeScrollBar( window, id, dirflags, propflags );
  1032.  *        struct Gadget *gp;
  1033.  *
  1034.  * INPUTS:    struct Window    *window;    window for gadget, or NULL
  1035.  *        USHORT        id;        non-zero id for gadget
  1036.  *        ULONG        propflags;  flags for PropInfo
  1037.  *        ULONG        myflags;    flags for routine
  1038.  *
  1039.  * DESCRIPTION: Creates an initialized scroll-bar (vertical or horizontal only),
  1040.  *        leaving room for the sizing gadget (whether or not it is there)
  1041.  *        to be placed in a window.
  1042.  *        If window is non-NULL, the gadget is further customized for
  1043.  *        the window (eg checks for GIMMEZEROZERO and calculates
  1044.  *        the PropInfo's HorizBody and VertBody), also the FgPen and BgPen
  1045.  *        colours of the window's rastport are used (see gimmePropGadget).
  1046.  *        The propflags are used by gimmePropInfo to set up the PropInfo
  1047.  *        structure for the scrollbar.
  1048.  *        Note: if you wish to change the knob imagery to your own, do
  1049.  *        something similar to the following after this routine:
  1050.  *            gp->GadgetRender = (APTR) <your image or border>;
  1051.  *            ((struct PropInfo *)gp->SpecialInfo)->Flags &= ~AUTOKNOB;
  1052.  *            gp->Flags &= ~GADGIMAGE;    ;; ONLY if you want a BORDER
  1053.  *
  1054.  *
  1055.  *        If all goes well, the head pointer to chained memory for the
  1056.  *        gadget and its other required structures is stored in the
  1057.  *        gp->UserData field. You must preserve this pointer!!
  1058.  *        If you need to use the UserData yourself, be sure to save
  1059.  *        gp->UserData somewhere safe after calling gimmeScrollBar.
  1060.  *        When you are done with the gadget you must ensure that the
  1061.  *        chained memory head pointer is restored into gp->UserData
  1062.  *        before you call getRidOfGadget.
  1063.  *
  1064.  * RESULTS:    Returns pointer to requested type of Gadget, or NULL.
  1065.  *        Note: The gadget is NOT added to the window.
  1066.  *
  1067.  * SEE ALSO:    getRidOfGadgets, gimmeFullScrollBar, gimmeOneScroll
  1068.  */
  1069.  
  1070. /*
  1071.  * NAME:    gimmeFullScrollBar
  1072.  *
  1073.  * SYNOPSIS:    gp = gimmeFullScrollBar( window, id, propflags, myflags,
  1074.  *                        id1, id2 );
  1075.  *        struct Gadget *gp;
  1076.  *
  1077.  * INPUTS:    struct Window    *window;    window for gadget, or NULL
  1078.  *        USHORT        id;        non-zero id for gadget
  1079.  *        ULONG        propflags;  flags for PropInfo
  1080.  *        ULONG        myflags;    flags for routine
  1081.  *        USHORT        id1;        id for left/up one-scroll gadget
  1082.  *        USHORT        id2;        id for right/down one-scroll gadget
  1083.  *
  1084.  * DESCRIPTION: Creates an initialized scroll-bar (vertical or horizontal)
  1085.  *        along with two one-scroll button gadgets at the ends of the
  1086.  *        scroll bar (hence the "full" designation),
  1087.  *        leaving room for the sizing gadget (whether or not it is there).
  1088.  *        If window is non-NULL, the gadget is further customized for
  1089.  *        the window (eg checks for GIMMEZEROZERO and calculates
  1090.  *        the PropInfo's HorizBody and VertBody).
  1091.  *        The propflags are used by gimmePropInfo to set up the PropInfo
  1092.  *        structure for the scrollbar.
  1093.  *
  1094.  *        Note: since the gadgets are linked together (with the scrollbar
  1095.  *        gadget first), be careful when using the gadget pointer returned
  1096.  *        by this function -- use addGadgets to add the list of gadgets,
  1097.  *        or follow the NextGadget pointers before chaining other gadgets
  1098.  *        to the end of these gadgets.
  1099.  *
  1100.  *        If all goes well, the head pointer to chained memory for the
  1101.  *        gadget and its other required structures is stored in the
  1102.  *        gp->UserData field. You must preserve this pointer!!
  1103.  *        If you need to use the UserData yourself, be sure to save
  1104.  *        gp->UserData somewhere safe after calling gimmeScrollBar.
  1105.  *        When you are done with the gadget you must ensure that the
  1106.  *        chained memory head pointer is restored into gp->UserData
  1107.  *        before you call getRidOfGadget.
  1108.  *
  1109.  * RESULTS:    Returns pointer to scroll-bar Gadget, to which the two
  1110.  *        one-scroll gadgets are linked, or NULL.
  1111.  *        Note: The gadgets are NOT added to the window.
  1112.  *
  1113.  * SEE ALSO:    getRidOfGadgets, gimmeScrollBar, gimmeOneScroll, addGadgets
  1114.  */
  1115.  
  1116. /*
  1117.  * NAME:    gimmeSound
  1118.  *
  1119.  *        #include <gimmelib/sound.h>
  1120.  *
  1121.  * SYNOPSIS:    snd = gimmeSound( filename );
  1122.  *        SOUND *snd;
  1123.  *
  1124.  * INPUTS:    UBYTE    *filename;        name of iff sound file
  1125.  *
  1126.  * DESCRIPTION: Read a sound sample from the specified file.
  1127.  *        Create and initialize a SOUND structure for the sound sample.
  1128.  *        If possible, an error message is printed if anything goes
  1129.  *        wrong -- it is safe to call this function from a (sub)task
  1130.  *        that has no CLI window.
  1131.  *
  1132.  *        Note: all allocated memory, including the SOUND struct itself,
  1133.  *        is chained and the header is stored in the SOUND's memhead
  1134.  *        field, which is used by getRidOfSound to deallocate memory.
  1135.  *
  1136.  * RESULTS:    Returns pointer to an initialized SOUND, or NULL on error.
  1137.  *
  1138.  * SEE ALSO:    getRidOfSound
  1139.  */
  1140.  
  1141. /*
  1142.  * NAME:    getRidOfSound
  1143.  *
  1144.  * SYNOPSIS:    err = getRidOfSound( sound );
  1145.  *        short err;
  1146.  *
  1147.  * INPUTS:    SOUND    *sound;     pointer to SOUND
  1148.  *
  1149.  * DESCRIPTION: De-allocate a SOUND structure that was dynamically
  1150.  *        allocated by gimmeSound.
  1151.  *
  1152.  * RESULTS:    Returns non-zero on error.
  1153.  *
  1154.  * SEE ALSO:    gimmeSound
  1155.  */
  1156.  
  1157. /*
  1158.  * NAME:    gimmeStdStuff
  1159.  *
  1160.  * SYNOPSIS:    error = gimmeStdStuff( myflags, revision );
  1161.  *        ULONG error;
  1162.  *
  1163.  * INPUTS:    ULONG    myflags;    flags for libraries/devices to open
  1164.  *        SHORT    revision;    revision number to use for OpenDevice()
  1165.  *
  1166.  * DESCRIPTION: Open standard libraries and devices and other things
  1167.  *        specified by the given myflags, using the given revision number.
  1168.  *        Pointers are stored in global variables in gimme.lib
  1169.  *        See gimmelib/stdstuff.h for the flags and variable names
  1170.  *        in order to find out what you can open with this routine.
  1171.  *
  1172.  *        Things are opened or initialized in the same order as the flags
  1173.  *        are listed (ie. in order of increasing importance!)
  1174.  *        except the special things (indicated by special bits).
  1175.  *
  1176.  *        NOTE: this routine is NOT reentrant; it can only be safely used
  1177.  *        by one task.
  1178.  *
  1179.  *        NOTE: it is not recommended to use any of the global variables
  1180.  *        associated with this routine for use without this routine and
  1181.  *        getRidOfStdStuff.
  1182.  *
  1183.  * RESULTS:    Returns zero if ok, otherwise flag corresponding to library
  1184.  *        or device that could not be opened.
  1185.  *        NOTE: returns on the first failure to open something.
  1186.  *
  1187.  * SEE ALSO:    getRidOfStdStuff
  1188.  */
  1189.  
  1190. /*
  1191.  * NAME:    getRidOfStdStuff
  1192.  *
  1193.  * SYNOPSIS:    error = getRidOfStdStuff( myflags );
  1194.  *        ULONG error;
  1195.  *
  1196.  * INPUTS:    ULONG    myflags;    special flags for closing devices
  1197.  *
  1198.  * DESCRIPTION: Close the standard libraries/devices/things opened by
  1199.  *        gimmeStdStuff.
  1200.  *        See gimmelib/stdstuff.h for the global variable names used.
  1201.  *        The myflags specify control flags, esp. with regard to handling
  1202.  *        errors encountered when closing devices.
  1203.  *
  1204.  *        Things are closed or reset in the *reverse* order as the flags
  1205.  *        are listed (ie. in order of decreasing importance!)
  1206.  *        except the special things (corresponding to the special bits).
  1207.  *
  1208.  *        NOTE: this routine is NOT reentrant; it can only be safely used
  1209.  *        by one task.
  1210.  *
  1211.  * RESULTS:    Returns zero if ok, otherwise flag corresponding to library
  1212.  *        or device that could not be closed.
  1213.  *        NOTE: returns on the first failure to close something.
  1214.  *
  1215.  * SEE ALSO:    getRidOfStdStuff
  1216.  */
  1217.  
  1218. /*
  1219.  * NAME:    gimmeSubTask
  1220.  *
  1221.  * SYNOPSIS:    task = gimmeSubTask( countptr, portptr, stacksize, datasize,
  1222.  *                                myportptr );
  1223.  *        struct Task *task;
  1224.  *
  1225.  * INPUTS:    SHORT        *countptr;  pointer to counter variable, or NULL
  1226.  *        struct MsgPort    **portptr;  pointer to a MsgPort ptr, or NULL
  1227.  *        LONG        stacksize;  size of stack for subtask
  1228.  *        LONG        datasize;   size of a startup data area for
  1229.  *                          the subtask, or 0L if none needed
  1230.  *        struct MsgPort **myportptr; pointer to a pointer where subtask
  1231.  *                          is to put its MsgPort ptr, or NULL
  1232.  *
  1233.  * DESCRIPTION: Set everything up to launch a subtask via startSubTask.
  1234.  *        It creates (and allocates memory) for the following:
  1235.  *        - a Task struct
  1236.  *        - a <stacksize>-byte stack
  1237.  *            - minimum approx 90 bytes used if <stacksize> is smaller
  1238.  *        - a <datasize>-byte data area
  1239.  *            - ONLY IF <datasize> is strictly positive
  1240.  *            - pointer to this data area stored in task->tc_UserData
  1241.  *            - pointer to this area will be passed as the single
  1242.  *              parameter to the subtask by startSubTask.
  1243.  *        - a special Message struct
  1244.  *            ONLY IF portptr and myportptr are non-NULL
  1245.  *            NOTE: when your subtask returns "normally" (ie you don't
  1246.  *            kill it), the default auto-clean-up routine will send
  1247.  *            a special "I'm dying" message to your task-monitoring port
  1248.  *            (indirectly pointed at by portptr) and *wait* for a reply
  1249.  *            (on the port it created for itself; see myportptr)
  1250.  *            before decrementing the subtask counter and removing
  1251.  *            itself from the system.
  1252.  *            Before your subtask exits, it should empty its message
  1253.  *            port and then (safely) NULL its port pointer (since a
  1254.  *            copy is kept by the subtasking "library") before it exits,
  1255.  *            so that (hopefully) other tasks will no longer put messages
  1256.  *            on its port (this will also help the auto-cleanup-routine).
  1257.  *        - a message port
  1258.  *            - ONLY IF myportptr is non-NULL
  1259.  *            - NOTE: the message port isn't actually created until
  1260.  *              the subtask starts running after you call startSubTask.
  1261.  *            - see note below.
  1262.  *
  1263.  *        Note: if myportptr is non-NULL, a non-public message port
  1264.  *        will be automagically created when the subtask starts
  1265.  *        *running* [after it has been started via startSubTask]
  1266.  *        and the pointer to this message port will be stored in what
  1267.  *        myportptr points to. Thus the port will exist and the pointer
  1268.  *        pointed at by myportptr will be valid when the actual code
  1269.  *        of the subtask starts (called by the subtask startup code).
  1270.  *        If at that time the message port cannot be created, the
  1271.  *        subtask will exit gracefully without ever entering your
  1272.  *        initial subtask code.
  1273.  *
  1274.  *        This function should be followed by initialization of the data
  1275.  *        area (if any) for the child task, then startSubTask
  1276.  *        OR use undoGimmeSubTask if you change your mind and don't
  1277.  *        want to start the subtask to free any allocated memory.
  1278.  *
  1279.  *        Use getRidOfTask to cleanly kill a subtask, or allow the
  1280.  *        default task-completion code for the subtask to clean up
  1281.  *        everything.
  1282.  *
  1283.  *        Note: countptr should be the same as was passed to
  1284.  *        initSubTasker, and portptr should be NULL or the same as
  1285.  *        passed to initSubTasker.
  1286.  *
  1287.  * RESULTS:    Returns a pointer to the Task struct,
  1288.  *        with task->tc_UserData pointing to the data area (if any)
  1289.  *        which is automatically passed as the only parameter to your
  1290.  *        subtask by startSubTask.
  1291.  *
  1292.  * SEE ALSO:    startSubTask, undoGimmeSubTask, getRidOfTask
  1293.  */
  1294.  
  1295. /*
  1296.  * NAME:    undoGimmeSubTask
  1297.  *
  1298.  * SYNOPSIS:    undoGimmeSubTask( task );
  1299.  *
  1300.  * INPUTS:    struct Task *task;        pointer to task struct
  1301.  *
  1302.  * DESCRIPTION: Free memory allocated for this subtask-in-the-making
  1303.  *        by gimmeSubTask.
  1304.  *
  1305.  *        NOTE: this is a "cancel!" function to be used after
  1306.  *        gimmeSubTask but before the task is actually
  1307.  *        started by startSubTask if you no longer want to submit
  1308.  *        the subtask.
  1309.  *
  1310.  * RESULTS:    The task pointer becomes invalid.
  1311.  *
  1312.  * SEE ALSO:    gimmeSubTask, killSubTask, startSubTask
  1313.  */
  1314.  
  1315. /*
  1316.  * NAME:    killSubTask
  1317.  *
  1318.  * SYNOPSIS:    killSubTask( countptr, portptr, task )
  1319.  *
  1320.  * INPUTS:    SHORT        *countptr;    ptr to counter variable, or NULL
  1321.  *        struct MsgPort    **portptr;    ptr to a MsgPort ptr, or NULL
  1322.  *        struct Task    *task;        ptr to an existing task
  1323.  *
  1324.  * DESCRIPTION: Remove the specified subtask from the system.
  1325.  *        Delete the port (if any) pointed at by what portptr points to.
  1326.  *        Note that the countptr and portptr parameters should be
  1327.  *        the same as was passed to initSubTasker.
  1328.  *
  1329.  * SEE ALSO:    gimmeSubTask, undoGimmeSubTask, startSubTask
  1330.  */
  1331.  
  1332. /*
  1333.  * NAME:    startSubTask
  1334.  *
  1335.  * SYNOPSIS:    error =  startSubTask( task, name, pri, initialpc, finalpc );
  1336.  *        short error;
  1337.  *
  1338.  *        struct Task *task;        pointer to task struct
  1339.  *        char        *name;        name for subtask
  1340.  *        BYTE        pri;        priority of subtask
  1341.  *        void        (*initialpc)();     address of routine for subtask
  1342.  *        void        (*finalpc)();       NULL - see note below
  1343.  *
  1344.  * DESCRIPTION: Start a subtask, ie. add it to the system.
  1345.  *        The task pointer must be the result of gimmeSubTask.
  1346.  *        Initialization of the data (if any) for the new task should
  1347.  *        already have been done before this routine.
  1348.  *        Note: regarding finalpc:
  1349.  *        - a value of NULL will cause the default cleanup
  1350.  *          routine getRidOfMyself to be used, which will
  1351.  *          handle things very nicely and cleanly.
  1352.  *        - Use your own finalpc routine AT YOUR OWN RISK!!!
  1353.  *        NOTE: the subtask counter [see countptr parameter for
  1354.  *        initSubTasker] gets incremented by the subtask itself
  1355.  *        once the subtask starts *running*!!!
  1356.  *
  1357.  *        WARNING: do NOT try to write to stdout or stderr
  1358.  *        (unless they are a file ??)
  1359.  *        or do a Write() to Output() from the subtask
  1360.  *        since it can be very bad for your health!!
  1361.  *
  1362.  * RESULTS:    Returns non-zero on error.
  1363.  *
  1364.  * SEE ALSO:    gimmeSubTask, undoGimmeSubTask, killSubTask
  1365.  */
  1366.  
  1367. /*
  1368.  * NAME:    initSubTasker
  1369.  *
  1370.  * SYNOPSIS:    error = initSubTasker( countptr, portptr );
  1371.  *        short error;
  1372.  *
  1373.  * INPUTS:    SHORT        *countptr;    ptr to counter variable, or NULL
  1374.  *        struct MsgPort    **portptr;    ptr to a MsgPort ptr, or NULL
  1375.  *
  1376.  * DESCRIPTION: Initialize the sub-tasking "library" mechanism by:
  1377.  *        - setting the counter to zero (pointed at by countptr).
  1378.  *        - if portptr is non-NULL, a message port is created, pointed
  1379.  *          at by what portptr points to.
  1380.  *        Note that the countptr and portptr parameters should be
  1381.  *        passed to certain other sub-tasking routines, such as:
  1382.  *        doneSubTasker, getRidOfSubTask and
  1383.  *        handleSpecialSubTaskMsg.
  1384.  *        A message port is only necessary if you use the dying-task-
  1385.  *        messages-its-parent or printf'ing from a subtask features;
  1386.  *        if you do not need these, portptr can be NULL and a message
  1387.  *        port will *not* be created.
  1388.  *
  1389.  * RESULTS:    Returns non-zero on error.
  1390.  *
  1391.  * SEE ALSO:    doneSubTasker, gimmeSubTask
  1392.  */
  1393.  
  1394. /*
  1395.  * NAME:    doneSubTasker
  1396.  *
  1397.  * SYNOPSIS:    error = doneSubTasker( countptr, portptr )
  1398.  *        short error;
  1399.  *
  1400.  * INPUTS:    SHORT        *countptr;    ptr to counter variable, or NULL
  1401.  *        struct MsgPort    **portptr;    ptr to a MsgPort ptr, or NULL
  1402.  *
  1403.  * DESCRIPTION: Finish access to the sub-tasking "library" mechanism by:
  1404.  *        - checking for outstanding subtasks via the counter variable
  1405.  *          pointed at by countptr (returns error if there are)
  1406.  *        - deletes message port (if any) created by initSubTasker and
  1407.  *          pointed at by what portptr points to.
  1408.  *        Note: the message port (if any) is *not* deleted if an error
  1409.  *        occurred.
  1410.  *        Note that the countptr and portptr parameters should be
  1411.  *        the same as was passed to initSubTasker.
  1412.  *
  1413.  * RESULTS:    Returns non-zero on error.
  1414.  *
  1415.  * SEE ALSO:    initSubTasker
  1416.  */
  1417.  
  1418. /*
  1419.  * NAME:    doPrintf
  1420.  *
  1421.  * SYNOPSIS:    error = doPrintf( port, replyport, s, p1, p2, p3, p4 )
  1422.  *        short error;
  1423.  *
  1424.  * INPUTS:    struct MsgPort    *port;        ptr to a Dos process' port
  1425.  *        struct MsgPort    *replyport;    your replyport or NULL
  1426.  *        UBYTE        *s;        a format string ala printf
  1427.  *        LONG        p1, p2;     4 parms for printf
  1428.  *        double        p3, p4;     see note below
  1429.  *
  1430.  * DESCRIPTION: Sends a message to a DOS process to print something.
  1431.  *        The DOS process in question must use handleSpecialSubTaskMsg
  1432.  *        to receive the print message.
  1433.  *        If replyport is NULL, doPrintf will not Wait() for a reply
  1434.  *        and the messaged process must do the FreeMem().
  1435.  *
  1436.  *        NOTE: The final string to be printed (ie. after processing
  1437.  *        by printf) should be no longer than 163 characters (which is
  1438.  *        approximately 2 full lines plus newlines) not including the
  1439.  *        final null character.
  1440.  *
  1441.  *        NOTE: the 4 printf parms (p1, p2, p3 and p4) do NOT have
  1442.  *        to match the long and double types exactly. This routine
  1443.  *        passes 4 parameters [ total size PARMS_SIZE calculated as:
  1444.  *          2 * sizeof(LONG) + 2 * sizeof(double)  ] to printf,
  1445.  *        which will only use what is required by the format
  1446.  *        string "s". This makes it possible to pass as printf parms
  1447.  *        the equivalent in size to 6 longwords. If this space isn't
  1448.  *        sufficient, several doPrintf's will be required.
  1449.  *        ==> This means that you can pass as many parameters as you
  1450.  *        want to doPrintf, but only up to the first PARMS_SIZE bytes
  1451.  *        will be used. This isn't exactly ANSI standard, but then
  1452.  *        again neither is the compiler.
  1453.  *
  1454.  *        NOTE: use synchronous printing VERY cautiously:
  1455.  *        the DOS process must be able to accept the message right
  1456.  *        away so you do not wait forever for a reply, and the first
  1457.  *        message on your replyport must be the reply to your print
  1458.  *        message (otherwise you screw up what arrives on your port).
  1459.  *
  1460.  * RESULTS:    Returns non-zero on error.
  1461.  *
  1462.  * SEE ALSO:    handleSpecialSubTaskMsg
  1463.  */
  1464.  
  1465. /*
  1466.  * NAME:    handleSpecialSubTaskMsg
  1467.  *
  1468.  * SYNOPSIS:    numdied = handleSpecialSubTaskMsg( countptr, portptr )
  1469.  *        SHORT numdied;
  1470.  *
  1471.  * INPUTS:    SHORT        *countptr;    ptr to counter variable, or NULL
  1472.  *        struct MsgPort    **portptr;    ptr to a MsgPort ptr
  1473.  *
  1474.  * DESCRIPTION: Handles special messages from subtasks, in particular
  1475.  *        "print" and "done" messages.
  1476.  *        If printing messages (say, from subtasks),
  1477.  *        this routine must be called from a DOS process, not a subtask
  1478.  *        otherwise nothing will get printed.
  1479.  *
  1480.  * RESULTS:    The number of "I'm dying" messages received from subtasks.
  1481.  *
  1482.  * SEE ALSO:    initSubTasker, doneSubTasker, doPrintf
  1483.  */
  1484.  
  1485. /*
  1486.  * NAME:    accessTimer
  1487.  *
  1488.  * REQUISITES:    struct Device *TimerBase;
  1489.  *
  1490.  * SYNOPSIS:    tr = accessTimer( unit, portptr );
  1491.  *        struct timerequest *tr;
  1492.  *
  1493.  * INPUTS:    ULONG    unit;            timer device unit
  1494.  *        struct MsgPort    **portptr;    pointer to a MsgPort ptr
  1495.  *
  1496.  * DESCRIPTION: Open the timer device.
  1497.  *        Allocates memory for a "master" time-request and initializes
  1498.  *        it for use with the timer device.
  1499.  *        The "unit" must be either UNIT_VBLANK or UNIT_MICROHZ.
  1500.  *        If portptr is non-NULL:
  1501.  *        - if the pointer that portptr points to is non-NULL,
  1502.  *          the time-request will use that port as a reply port.
  1503.  *        - otherwise a reply port is created and a pointer to it is
  1504.  *          stuffed into what portptr points at.
  1505.  *        If portptr is NULL, a message port will be created but you
  1506.  *        would have to snoop around the time-request struct to find
  1507.  *        a pointer to it.
  1508.  *        NOTE: make sure what portptr points to is NULL if it is not
  1509.  *        a valid pointer (ie initialize it).
  1510.  *
  1511.  *        NOTE: you must end any and all "slave" time-requests
  1512.  *        you create [via gimmeTimeRequest] by using
  1513.  *        getRidOfTimeRequest on each "slave" before releasing access
  1514.  *        to the timer via releaseTimer on the "master" time-request.
  1515.  *
  1516.  *        Note: you must have declared a global variable as follows:
  1517.  *            struct Device *TimerBase = NULL;
  1518.  *        The actual pointer will be stored in the TimerBase variable
  1519.  *        by this routine [after opening the timer device].
  1520.  *
  1521.  * RESULTS:    Returns a pointer to a "master" time-request, or NULL.
  1522.  *
  1523.  * SEE ALSO:    releaseTimer, gimmeTimeRequest, getRidOfTimeRequest
  1524.  */
  1525.  
  1526. /*
  1527.  * NAME:    releaseTimer
  1528.  *
  1529.  * SYNOPSIS:    error = releaseTimer( tr, saveport );
  1530.  *        LONG error;
  1531.  *
  1532.  * INPUTS:    struct timerequest  *tr;    ptr to "master" time-request
  1533.  *        struct MsgPort        *saveport;    ptr to msgport to save, or NULL
  1534.  *
  1535.  * DESCRIPTION: Close the timer device and free the memory of the "master"
  1536.  *        time-request.
  1537.  *        If saveport is NULL, the port associated with the given
  1538.  *        "master" time-request will be deleted (not necessarily the
  1539.  *        same one as the saveport specified in the parameters).
  1540.  *        If saveport is non-NULL, no message port will be deleted.
  1541.  *
  1542.  *        NOTE: you must have ended any and all "slave" time-requests
  1543.  *        you created [via gimmeTimeRequest] by using
  1544.  *        getRidOfTimeRequest on each "slave" BEFORE calling this
  1545.  *        function.
  1546.  *
  1547.  * RESULTS:    Returns non-zero ala AbortIO() on error.
  1548.  *
  1549.  * SEE ALSO:    accessTimer, gimmeTimeRequest, getRidOfTimeRequest
  1550.  */
  1551.  
  1552. /*
  1553.  * NAME:    gimmeTimeRequest
  1554.  *
  1555.  * SYNOPSIS:    tr = gimmeTimeRequest( trmaster );
  1556.  *        struct timerequest *tr;
  1557.  *
  1558.  * INPUTS:    struct timerequest  *trmaster;        ptr to "master" time-request
  1559.  *
  1560.  * DESCRIPTION: Allocate memory for a "slave" time-request and initializes
  1561.  *        it from the "master" time-request.
  1562.  *        This "slave" timerequest will use the same timer unit
  1563.  *        (either UNIT_VBLANK or UNIT_MICROHZ) and reply port
  1564.  *        as the "master" time-request.
  1565.  *        NOTE: you must end all "slave" time-requests
  1566.  *        via getRidOfTimeRequest before releasing access to the
  1567.  *        timer via releaseTimer using the "master" time-request.
  1568.  *
  1569.  * RESULTS:    Returns a pointer to a "slave" time-request, or NULL.
  1570.  *
  1571.  * SEE ALSO:    accessTimer, getRidOfTimeRequest, releaseTimer
  1572.  */
  1573.  
  1574. /*
  1575.  * NAME:    getRidOfTimeRequest
  1576.  *
  1577.  * SYNOPSIS:    error = getRidOfTimeRequest( tr );
  1578.  *        LONG error;
  1579.  *
  1580.  * INPUTS:    struct timerequest  *tr;    pointer to "slave" time-request,
  1581.  *                          as returned by gimmeTimeRequest
  1582.  *
  1583.  * DESCRIPTION: Free memory taken by the "slave" time-request, rendering
  1584.  *        the pointer <tr> invalid.
  1585.  *        The time-request will be aborted if it is currently in
  1586.  *        progress.
  1587.  *
  1588.  * RESULTS:    Returns zero if ok, or non-zero ala AbortIO() on error.
  1589.  *        Either way, the time-request gets freed and <tr> becomes
  1590.  *        an invalid pointer.
  1591.  *
  1592.  * SEE ALSO:    gimmeTimeRequest, accessTimer, releaseTimer
  1593.  */
  1594.  
  1595. /*
  1596.  * NAME:    timeDelay
  1597.  *
  1598.  * SYNOPSIS:    error = timeDelay( secs, micros, unit, mytr );
  1599.  *        LONG error;
  1600.  *
  1601.  * INPUTS:    ULONG            secs;    number of seconds to delay
  1602.  *        ULONG            micros;    number of microseconds to delay
  1603.  *        ULONG            unit;    timer device unit
  1604.  *        struct timerequest  *mytr;    ptr to a time-request, or NULL
  1605.  *
  1606.  * DESCRIPTION: Delay a specified amount of time using Synchronous IO.
  1607.  *        If mytr is non-NULL, that time-request is used, otherwise a
  1608.  *        "master" timerequest" is created via accessTimer.
  1609.  *        The unit must be either UNIT_VBLANK or UNIT_MICROHZ,
  1610.  *        but is ignored if myptr is non-NULL.
  1611.  *        The "tv" parameter should point to a timeval struct which
  1612.  *        contains the number of seconds and microseconds to wait.
  1613.  *
  1614.  *        Note: this function can be used completely stand-alone if
  1615.  *        the "mytr" parameter is NULL, or in conjunction with other
  1616.  *        timer routines such as accessTimer and gimmeTimeRequest.
  1617.  *
  1618.  * RESULTS:    Returns non-zero on error.
  1619.  *
  1620.  * SEE ALSO:    accessTimer, releaseTimer
  1621.  */
  1622.  
  1623. /*
  1624.  * NAME:    timeDelayAsync
  1625.  *
  1626.  * SYNOPSIS:    tr = timeDelayAsync( secs, micros, unit, mytr );
  1627.  *        struct timerequest *tr;
  1628.  *
  1629.  * INPUTS:    ULONG            secs;    number of seconds to delay
  1630.  *        ULONG            micros;    number of microseconds to delay
  1631.  *        ULONG            unit;    timer device unit
  1632.  *        struct timerequest  *mytr;    ptr to a time-request, or NULL
  1633.  *
  1634.  * DESCRIPTION: Send a delay request using Asynchronous IO.
  1635.  *        If mytr is non-NULL, that time-request is used, otherwise
  1636.  *        a "master" time request with no reply port is created via
  1637.  *        accessTimer.
  1638.  *        The unit must be either UNIT_VBLANK or UNIT_MICROHZ,
  1639.  *        but is ignored if myptr is non-NULL.
  1640.  *        The "tv" parameter should point to a timeval struct which
  1641.  *        contains the number of seconds and microseconds to wait.
  1642.  *
  1643.  *        Note: if mytr is NULL, you must remove the time-request via
  1644.  *        releaseTimer when you are signalled that it is done.
  1645.  *
  1646.  * RESULTS:    Returns a pointer to a time-request (either the same one
  1647.  *        passed as a parameter or a new "master" time-request),
  1648.  *        or NULL on error.
  1649.  *
  1650.  * SEE ALSO:    accessTimer, releaseTimer
  1651.  */
  1652.  
  1653. /*
  1654.  * NAME:    waitTimer
  1655.  *
  1656.  * SYNOPSIS:    error = waitTimer( tr );
  1657.  *        LONG error;
  1658.  *
  1659.  * INPUTS:    struct timerequest  *tr;    time-request to wait for
  1660.  *
  1661.  * DESCRIPTION: Wait for the specified time-request to complete.
  1662.  *        Usually used after an Asynchronous time delay,
  1663.  *        eg. using timeDelayAsync.
  1664.  *
  1665.  * RESULTS:    Returns non-zero on error, ala WaitIO().
  1666.  *
  1667.  * SEE ALSO:    accessTimer, releaseTimer, gimmeTimeRequest, timeDelayAsync
  1668.  */
  1669.  
  1670. /*
  1671.  * NAME:    killTimeDelay
  1672.  *
  1673.  * SYNOPSIS:    error = killTimeDelay( tr );
  1674.  *        LONG error;
  1675. SHAR_EOF
  1676. #    End of shell archive
  1677. exit 0
  1678. -- 
  1679. Bob Page, U of Lowell CS Dept.  page@swan.ulowell.edu  ulowell!page
  1680. Have five nice days.
  1681.